
import config from '../config/index';
import request from '../utils/request';

const BASE_URL = config.BASE_URL;

//登陆
export async function login(params){
    return request(`${BASE_URL}/login`, {
        method: 'POST',
        body: {
          ...params,
        },
      });
}

//退出登录
export async function loginOut(params){
  return request(`${BASE_URL}/login/logout`, {
    method: 'POST',
    body: {
      ...params,
    },
  }); 
}

//获取用户信息
export async function getUserInfo(){
  return request(`${BASE_URL}/user/getUserInfo`);
}

//获取菜单
export async function getMenu(){
  return request(`${BASE_URL}/menu/getAll`);
}

//获取更改服务通知列表
export async function getAllChange(){
  return request(`${BASE_URL}/changeService/selectAllChange`);
}

//获取更改服务详情
export async function changeService(params){
  return request(`${BASE_URL}/changeService/changeService`,{
    method: 'POST',
    body: {
      ...params,
    },
  });
}

//查询服务人员服务历史记录
export async function selectElderlyInfo(params){
  return request(`${BASE_URL}/serviceStaff/selectElderlyInfo`,{
    method: 'POST',
    body: {
      ...params,
    },
  });
}
//查询老人享受服务历史记录
export async function selectInfoByTime(params){
  return request(`${BASE_URL}/enderly/selectInfoByTime`,{
    method: 'POST',
    body: {
      ...params,
    },
  });
}


//按照分页查询服务，不分页传{"pageCurrent": 0,"pageSize": 0}
export async function serviceTypeAll(params){
  return request(`${BASE_URL}/serviceType/selectAll`, {
      method: 'POST',
      body: {
        ...params,
      },
    });
}

//获取老人管理列表
export async function getOldList(params){
    return request(`${BASE_URL}/enderly/selectByPage`, {
        method: 'POST',
        body: {
          ...params,
        },
      });
}

//老人管理——获取列表,按条件查询
export async function getInfo(params){
  return request(`${BASE_URL}/enderly/selectAll`, {
    method: 'POST',
    body: {
      ...params,
    },
  });
}

//老人管理——查看详情
export async function getOldInfo(params){
  return request(`${BASE_URL}/enderly/selectElderlyDetails/${params}`); 
}

//老人管理——新增
export async function InsertOldList(params){
    return request(`${BASE_URL}/enderly/insert`, {
        method: 'POST',
        body: {
          ...params,
        },
      });
}

//老人管理——删除
export async function deleteList(params){
   return request(`${BASE_URL}/enderly/deleteBatch`,{
    method: 'POST',
    body:  params,
  }) 
}

//服务人员管理——新增
export async function insertServiceStaff(params){
  return request(`${BASE_URL}/serviceStaff/insert`, {
      method: 'POST',
      body: {
        ...params,
      },
    });
}

//老人管理——修改
export async function upOldInfo(params){
  return request(`${BASE_URL}/enderly/update`,{
   method: 'POST',
   body:  params,
 }) 
}

//服务人员管理——修改
export async function updateServiceStaff(params){
  return request(`${BASE_URL}/serviceStaff/update`, {
      method: 'POST',
      body: {
        ...params,
      },
    });
}

//服务人员管理——删除
export async function deleteServiceStaff(params){
  return request(`${BASE_URL}/serviceStaff/deleteBatch`, {
      method: 'POST',
      body: params,
    });
}

//服务人员管理——详情
export async function serviceStaffDetail(params){
  return request(`${BASE_URL}/serviceStaff/selectById/${params}`, {
      method: 'GET',
    });
}

//区域管理——获取区域树
export async function selectDeptTree(){
  return request(`${BASE_URL}/dept/selectAllTree`,{
   method: 'GET'
 }) 
}

//获取性别
export async function getGender(params){
  return request(`${BASE_URL}/enderly/selectGender`,{
   method: 'POST',
   body:  params,
 }) 
}

//获取服务负责人信息
export async function getServicePeople(params){
  return request(`${BASE_URL}/serviceStaff/selectAll`,{
   method: 'POST',
   body:  params,
 }) 
}

//分配人员接口
export async function getDistributeP(params){
  return request(`${BASE_URL}/enderly/giveServiceStaff`,{
   method: 'POST',
   body:  params,
 }) 
}

//获取角色
export async function getrole(params){
  return request(`${BASE_URL}/role/selectAllRole`,{
   method: 'POST',
   body:  params,
 }) 
}
export async function selectChargeType(){
  return request(`${BASE_URL}/parameter/selectchargetype`,{
   method: 'GET'
 }) 
}

//服务记录查询接口
export async function getRecordList(params){
  return request(`${BASE_URL}/serviceRecord/seleteAll`,{
   method: 'POST',
   body:  params,
 }) 
}


// 服务记录删除接口
export async function delRecordList(params) {
  return request(`${BASE_URL}/serviceRecord/deleteBatch`,{
    method: 'POST',
    body:  params,
  }) 
}

// 回访信息
export async function getVisitedList() {
  return request(`${BASE_URL}/serviceRecord/visited`,{
    method: 'POST',
  }) 
}

  //新增服务类型
export async function insertServiceType(params){
  return request(`${BASE_URL}/serviceType/insert`,{
   method: 'POST',
   body:  params,
 }) 
}

  //新增服务类型
  export async function updateServiceType(params){
    return request(`${BASE_URL}/serviceType/update`,{
     method: 'POST',
     body:  params,
   }) 
  }

    //删除服务类型
    export async function deleteServiceType(params){
      return request(`${BASE_URL}/serviceType/delete`,{
       method: 'POST',
       body:  params,
     }) 
    }

  
// 获取区域详情
export async function getAreaDetail(param) {
  return request(`${BASE_URL}/dept/selectDeptById/${param}`);
}

// 通过区域id获取区域用户列表
export async function getUserByDeptId(param) {
  return request(`${BASE_URL}/dept/selectUserByDeptId/${param}`)
}

// 通过服务记录id查询服务记录详情
export async function getRecrodByfid(param) {
  return request(`${BASE_URL}/serviceRecord/selectServiceRecord/${param}`)
}

// 用户删除
export async function userDel(params) {
  return request(`${BASE_URL}/user/delUser`, {
    method: 'POST',
    body:  params,
  })
} 

// 用户新增
export async function userAdd(params) {
  return request(`${BASE_URL}/user/addUser`, {
    method: 'POST',
    body:  params,
  })
} 
// 用户新增
export async function userUpdate(params) {
  return request(`${BASE_URL}/user/updateUserById`, {
    method: 'POST',
    body:  params,
  })
} 


// 查询角色
export async function selectAllRole() {
  return request(`${BASE_URL}/role/selectAllRole`)
}

// 新增区域
export async function addArea (params) {
  return request(`${BASE_URL}/dept/addDept` , {
    method: 'POST',
    body:  params,
  })
}

//添加角色
export async function addRole(params) {
  return request(`${BASE_URL}/role/insertRole`, {
    method: 'POST',
    body:  params,
  })
}

export async function getMenuByRoleId(param) {
  return request(`${BASE_URL}/role/getMenuByRoleId/${param}`)
}

// 更新区域列表
export async function updateDept(params) {
  return request(`${BASE_URL}/dept/updateDept`, {
    method: 'POST',
    body:  params,
  })
}

// 删除区域
export async function delDept(param) {
  return request(`${BASE_URL}/dept/delDept/${param}`)
}

// 获取所有权限接口
export async function selectAllMenu() {
  return request(`${BASE_URL}/menu/getAll`)
}

// 更新角色
export async function updateRole(params) {
  return request(`${BASE_URL}/role/updateRole`, {
    method: 'POST',
    body:  params,
  })
}

// 删除角色
export async function delRole(param) {
  return request(`${BASE_URL}/role/delRole/${param}`);
}

//回访管理——保存
export async function putInfoVisit(param){
  return request(`${BASE_URL}/serviceRecord/update`, {
    method: 'POST',
    body:  param,
  })
  
}

//导出服务人员管理记录
export async function exportService(param){
  return request(`${BASE_URL}/export/exportServiceElderly`, {
    method: 'POST',
    body:  param,
  })
}

//导出老人信息
export async function exportElderly(param){
  return request(`${BASE_URL}/export/exportElderlyAccountInfo`, {
    method: 'POST',
    body:  param,
  })
}

//导出服务记录
export async function exportServiceRecord(param){
  return request(`${BASE_URL}/export/servicerecord`, {
    method: 'POST',
    body:  param,
  })
}





